import {
	http
} from "/utils/http.js";


export const getOrdersAPI = () => {
	return http({
		method: 'GET',
		url: '/common/listAll',
	})
}

//根据id查询全部订单
export const getOrdersById = (identity, id) => {
	return http({
		method: 'GET',
		url: `/api/${identity}/list/${id}`
	})
}

//根据用户id查询未签字的合同
export const getContractByIdAPI = (orderId) => {
	return http({
		method: 'GET',
		url: `/api/pdf/longimage/${orderId}`,
		timeout: 20000
	})
}

//根据订单id, 上传甲乙方签名
export const uploadSignatureByIdAPI = (party, orderId, base64) => {
	return http({
		method: 'POST',
		url: `/api/signature/${party}/upload/${orderId}`,
		data: {
			file: base64
		},
		header: {
			'content-type': 'application/x-www-form-urlencoded'
		}
	})
}

// 根据订单id修改订单状态
export const updateOrderStateAPI = (orderId, state) => {
	return http({
		method: 'POST',
		url: '/api/tourist/updateToBeSign',
		data: {
			orderId,
			state
		},
		header: {
			'content-type': 'application/x-www-form-urlencoded'
		}
	})
}
//根据id查询订单详情
export const getOrderDetailByIdAPI = (orderId) => {
	return http({
		method: 'GET',
		url: `/api/tourist/getOrderById/${orderId}`
	})
}

//根据code获取用户openid
export const getOpenidByCodeAPI = (code) => {
	return http({
		method: 'GET',
		url: '/api/getOpenId',
		data: {
			code,
		}
	})
}

//根据userId判断游客是否绑定业务员
export const isBindAgentAPI = (userId) => {
	return http({
		method: 'GET',
		url: `/api/tourist/isBindWithAgent/${userId}`
	})
}

//游客与业务员绑定
export const bindUserAndAgentAPI = (agentId, userId) => {
	return http({
		method: 'POST',
		url: '/api/tourist/bindUserAndAgent',
		data: {
			agentId,
			userId
		},
		header: {
			'content-type': 'application/x-www-form-urlencoded'
		}
	})
}